package com.zhkj.crawl.config;

import lombok.Data;

@Data
public class FetchRankException extends RuntimeException{

    public enum Type{
        INVALID("商品已失效(404)"),
        NONE_INFO("3无数据(排行/星级/评论)"),
        ;
        public String msg;
        Type(String msg) {
            this.msg = msg;
        }
    }

    private Type errType;
    private String url;

    public FetchRankException(Type errType) {
        this.errType = errType;
    }

    public FetchRankException(String message, Type errType) {
        super(message);
        this.errType = errType;
    }

    public FetchRankException(String message, Type errType, String url) {
        super(message);
        this.errType = errType;
        this.url = url;
    }

    public FetchRankException(String message, Throwable cause, Type errType) {
        super(message, cause);
        this.errType = errType;
    }

    public FetchRankException(Throwable cause, Type errType, String url) {
        super(cause);
        this.errType = errType;
        this.url = url;
    }


    public static FetchRankException invalidExp(String msg){
        return new FetchRankException(msg, Type.INVALID);
    }
}
